/*
 *                    COPYRIGHT NOTICE
 *
 *           This code is copyright protected by Freedom Inc.
 *
 *              2001-2012 All Rights Are Reserved
 */
package com.freedom.oldsong.system;

import java.util.List;

import org.springframework.dao.DataAccessException;

import com.freedom.oldsong.system.dto.PaginationResult;

/**
 * @author steven.wang
 *
 * @param <T>
 */
public interface BaseDao<T> {
	
	/**
	 * @param id
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteByPrimaryKey(Long id) throws DataAccessException;
	
	/**
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	public Long insert(T record) throws DataAccessException;

	/**
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	public Long insertSelective(T record) throws DataAccessException;

	/**
	 * @param id
	 * @return
	 * @throws DataAccessException
	 */
	public T selectByPrimaryKey(Long id) throws DataAccessException;

	/**
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	public int updateByPrimaryKeySelective(T record) throws DataAccessException;

	/**
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	public int updateByPrimaryKey(T record) throws DataAccessException;
	
	/**
	 * @param queryName
	 * @param objects
	 * @return
	 * @throws DataAccessException
	 */
	public List<?> queryForList(String queryName, Object... objects) throws DataAccessException;

	/**
	 * @param queryName
	 * @param objects
	 * @return
	 * @throws DataAccessException
	 */
	public Object queryForObject(String queryName, Object... objects) throws DataAccessException;
	
	/**
	 * @return
	 */
	public String getNameMapping();
	
	/**
	 * @param query
	 * @param sort
	 * @param pageSize
	 * @param currentPage
	 * @param parameters
	 * @return
	 * @throws DataAccessException
	 */
	public PaginationResult selectForPagination(String query, PaginationResult paginationResult, Object... parameters) throws DataAccessException;
}
